package com.junxonline.instant.common.entity.common;

import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.serializer.ToStringSerializer;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 公共实体对象（数据权限）
 *
 * @author JunX
 * @date 2021-12-28
 */
@Data
public class CommonDataScopeEntity implements Serializable {

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    protected Date createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    protected Date updateTime;

    /**
     * 创建人
     */
    @TableField(value = "create_id", fill = FieldFill.INSERT)
    @JSONField(serializeUsing = ToStringSerializer.class)
    protected Long createId;

    /**
     * 更新人
     */
    @TableField(value = "update_id", fill = FieldFill.INSERT_UPDATE)
    @JSONField(serializeUsing = ToStringSerializer.class)
    protected Long updateId;

    /**
     * 权限参数
     */
    protected Map<String, Object> dataScopeParams;

    /**
     * 重写Getter方法
     *
     * @return Map<String, Object>
     */
    public Map<String, Object> getDataScopeParams() {
        if (dataScopeParams == null) {
            dataScopeParams = new HashMap<>();
        }
        return dataScopeParams;
    }
}
